/**  
 * Project Name:sz-yrp  
 * File Name:TimedTaskService.java  
 * Package Name:sz.com.yrp.yangtze.timetask.service  
 * Date:2020年8月28日上午9:55:43  
 * Copyright (c) 2020, mengwangq@isoftstone.com All Rights Reserved.  
 *  
*/  
  
package com.atxiaodei.springcloud.sshtimedtask.service;

import com.atxiaodei.springcloud.sshtimedtask.scpssh.ScpSshConnectionClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**  
 * ClassName:TimedTaskService <br/>  
 * Function: TODO ADD FUNCTION. <br/>  
 * Reason:   TODO ADD REASON. <br/>  
 * Date:     2020年8月28日 上午9:55:43 <br/>  
 * @author   wangmeng  
 * @version    
 * @since    JDK 1.8  
 * @see        
 */
@Slf4j
@Service
public class TimedTaskService {
	
	// ps -ef | grep xxx.log | grep -v grep | awk '{print $2}' 查询服务器上某个进程的进程号 这个我的是一个推送流的进程号
	private static final String execFindGrep="ps -aux|grep rtsp_transport | grep -v grep | awk '{print $2}'";
	
	private static final String killProcess="kill -9 "; 
	
	public String execGrepResult(){
		log.info("准备执行命令："+execFindGrep);
		return ScpSshConnectionClient.execute(execFindGrep);// 查询返回的进程号
	}
	
	public void execKileProcess(String cmd){
		log.info("准备执行命令："+killProcess+cmd);
		ScpSshConnectionClient.execute(killProcess+cmd);// 这里批量处理
	}
	

}
  
